﻿/*
 * KLF Headless Browser
 * Written by Kris Oye <kristianoye@gmail.com>
 * Copyright (C) 2011-2012.  All rights reserved.
 */
namespace KLF.Lib.Browser.DOM.Style
{
    #region Using Statements

    using System;
    using System.Collections;
    using System.Collections.Generic;

    #endregion

    public class StyleSheetList
    {
        #region Attributes

        public List<StyleSheet> Items { get; set; }

        #endregion

        #region DOM Level 2 Style Compliance

        /// <summary>
        /// Shortcut for item(index).
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public StyleSheet this[int index]
        {
            get
            {
                return item(index);
            }
        }

        /// <summary>
        /// Used to retrieve a style sheet by ordinal index. If index is 
        /// greater than or equal to the number of style sheets in the 
        /// list, this returns null. 
        /// </summary>
        /// 
        /// <param name="index">Index into the collection</param>
        /// 
        /// <returns>The style sheet at the index position in the 
        /// StyleSheetList, or null if that is not a valid index.</returns>
        public StyleSheet item(int index)
        {
            return (index > -1 && index < Items.Count ? Items[index] : null);
        }

        /// <summary>
        /// The number of StyleSheets in the list. The range of valid child 
        /// stylesheet indices is 0 to length-1 inclusive.
        /// </summary>
        public int length
        {
            get
            {
                return Items.Count;
            }
        }

        #endregion
    }
}
